package com.zimi.code.controller;

import com.zimi.code.service.CodeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CodeApi {

    private final CodeService codeService;

    @Autowired
    public CodeApi(CodeService codeService) {
        this.codeService = codeService;
    }

    @RequestMapping(value = "code", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation("代码生成器")
    public Object generator(String str) {
        return codeService.generator(str);
    }
}
